Label object
File: label.m
Location: ..\cubatch\label.m
function Labels =
label(Lab,DefLab,Scalars,AxisLabels,Name,MeasUn)
Inputs:
Lab: can be char array or cell vector of chars or
vector of doubles. In the latter case
the labels are in the form [DefLab number]. If scalars is defined this field is
not necessary
DefLab: default: 'Var.'
Scalars: scalars to plot against. If Lab is empty the labels are in the
form [scalar MeasUn]
MeasUn: default: ''
AxisLabels: char array or cell vector of arrays
Name: name of the label object
Outputs:
Labels: label object
Description:
A label object can refer to any dimension in a multidimensional array.
Assuming that one has a data set of dimensions 20 x 4 x 10, where the first
dimension represents the samples,
the second the concentration of 4 different compounds and the third the
measurement times (from 1 to 28 seconds
every third second).
One can than create three label objects respectively having length 20, 4 and 10.
»Lab1 = label(1:20,'Sam',[],'Samples','Samples');
»Lab2 = label({'Tryptophan','DOPA','Tyrosine','Phenilalanine'},'Comp.',[],...
'Compounds','Compounds');
»Lab3 = label([],'',1:3:28,'Time (s)','Time','s');
»Lab1,Lab2,Lab3
Lab1
Lab2
Lab3
Name : Samples
Meas. unit:
Def. label: Sam
Axis label: Samples
Labels : Sam 1
Sam 2
Sam 3
Sam 4
Sam 5
Sam 6
Sam 7
Sam 8
Sam 9
Sam 10
Sam 11
Sam 12
Sam 13
Sam 14
Sam 15
Sam 16
Sam 17
Sam 18
Sam 19
Sam 20Name : Compounds
Meas. unit:
Def. label: Comp.
Axis label: Compounds
Labels : Tryptophan
DOPA
Tyrosine
PhenilalanineName : Time
Meas. unit: s
Def. label:
Axis label: Time (s)
Labels : 1 s
4 s
7 s
10 s
13 s
16 s
19 s
22 s
25 s
28 s
The label object can be treated as a normal vector:
» t = Lab1(1:2:end)
Name : Samples
Meas. unit:
Def. label: Sam
Axis label: Samples
Labels : Sam 1
Sam 3
Sam 5
Sam 7
Sam 9
Sam 11
Sam 13
Sam 15
Sam 17
Sam 19
and t is a 10 x 1 label object:
» whos t
Name Size Bytes Class
t 10x1 2116 label object
To access labels, scalars and the other properties of the label object one can use a dot as for structures:
» Lab1.labels
ans =
'Sam 1'
'Sam 2'
'Sam 3'
'Sam 4'
'Sam 5'
'Sam 6'
'Sam 7'
'Sam 8'
'Sam 9'
'Sam 10'
'Sam 11'
'Sam 12'
'Sam 13'
'Sam 14'
'Sam 15'
'Sam 16'
'Sam 17'
'Sam 18'
'Sam 19'
'Sam 20'» Lab3.scalars
ans =
1
4
7
10
13
16
19
22
25
28
» Lab2.axislabels
ans =
'Compounds'
» Lab2.deflab
ans =
Comp.
» Lab2.name
ans =
Compounds
Complex constructions are also allowed for reference, e.g.
» Lab1(1:2:end).labels
ans =
'Sam 1'
'Sam 3'
'Sam 5'
'Sam 7'
'Sam 9'
'Sam 11'
'Sam 13'
'Sam 15'
'Sam 17'
'Sam 19'
The scalars and the labels are kept together:
» p = Lab3(1:5) » p.scalars Name : Time
Meas. unit: s
Def. label:
Axis label: Time (s)
Labels : 1 s
4 s
7 s
10 s
13 sans =
1
4
7
10
13
The 'Def. label' (default label) is used to
reconstruct undefined labels:
» Lab(11:15)=Lab1(1:5)
Name :
Meas. unit:
Def. label: Var.
Axis label:
Labels : Var. 1
Var. 2
Var. 3
Var. 4
Var. 5
Var. 6
Var. 7
Var. 8
Var. 9
Var. 10
Sam 1
Sam 2
Sam 3
Sam 4
Sam 5
because the default value for 'Def. label' is 'Var.' and Lab is an empty undefined matrix
» Lab1(25)='Sample 30'
Name : Samples
Meas. unit:
Def. label: Sam
Axis label: Samples
Labels : Sam 1
Sam 2
Sam 3
Sam 4
Sam 5
...
...
Sam 20
Sam 21
Sam 22
Sam 23
Sam 24
Sample 30
The labels between 21 and 24 are created automatically
according to 'Def. label' (for Lab1:
'Sam')
The assigned value can either be a char array, a cell vector containing only strings or another label object.
E.g.:
» t={'Fluoranthene','Nonylphenol'}';
» Lab2(6:7)=t
Name : Compounds
Meas. unit:
Def. label: Comp.
Axis label: Compounds
Labels : Tryptophan
DOPA
Tyrosine
Phenilalanine
Comp. 5
Fluoranthene
Nonylphenol
Note that t must be a column cell vector otherwise the
operation will return the original label object
There is no filling in for the scalars themselves, which are instead turned
automatically to 1:length(label) in
case the filling for the labels by means of 'Def. label'
is applied. Hence if one defines the labels by scalars
it is basically not possible to update the label object without updating all the
scalars at the same time,
otherwise all the scalars are lost:
» Lab3.scalars = [2:3:29]
Name : Time
Meas. unit: s
Def. label:
Axis label: Time (s)
Labels : 2 s
5 s
8 s
11 s
14 s
17 s
20 s
23 s
26 s
29 s
The length on the two sides of an assignment must be the
same:
» Lab3.scalars = [2:3:22]
??? Error using ==> label/subsasgn
Unequal lengths
If one redefines one or more of the actual labels of a label object defined by
scalars, the label update based on the automatic scheme [number
measurement-unit] stops working, hence upon modification of the scalars, the
labels remain the same:
» Lab3(1)='Null'
Name : Time
Meas. unit: s
Def. label:
Axis label: Time (s)
Labels : Null
5 s
8 s
11 s
14 s
17 s
20 s
23 s
26 s
29 s
» Lab3.scalars = 1:3:28
Name : Time
Meas. unit: s
Def. label:
Axis label: Time (s)
Labels : Null
5 s
8 s
11 s
14 s
17 s
20 s
23 s
26 s
29 s
Methods:
Only a few functions are defined on the label object:
Related objects: Content, CBDataSet
Author:
Giorgio Tomasi
Royal Agricultural and Veterinary University
MLI, LMT, Chemometrics group
Rolighedsvej 30
DK-1958 Frederiksberg C
Danmark
Last modified: 17 Aug. 2002
Contact: Giorgio Tomasi,
gt@kvl.dk